package com.bigflexlib.x.Math
{


	/**
	 * 
	 * 
	 * 
	 * @author aldo.bucchi@gmail.com
	 * 
	 */
	public class NormalizedFactor
	{
		
		
		//////////////////////////////////
		// factor
		//////////////////////////////////
		
		private var _factor:Number;
		public function get factor( ):Number
		{
			return _factor;
		}
		

		//////////////////////////////////
		// value
		//////////////////////////////////
		
		private var _value:Number;
		
		public function get value( ):Number
		{
			return _value;
		}		
		

		
		//////////////////////////////////
		// isDivision
		//////////////////////////////////
		
		private var _isDivision:Boolean;
		
		public function get isDivision( ):Boolean
		{
			return _isDivision;	
		}
		
		
		
		
		public function NormalizedFactor( value:Number )
		{

			_value = value;
			
			_isDivision = Math.abs( value ) < 1;
			
			if ( value == 0 ) // border case ( we cannot divide by zero )
				_isDivision = false;

			if ( _isDivision )
				_factor = 1 / _value;
			else
				_factor = _value;

		}
		
		
		
		
		public function ponderate( num:Number ):Number
		{
			
			var newFactor:Number = 1 + ( ( _factor-1 ) * num );
			
			if ( _isDivision )
				return 1 / newFactor;
			
			return newFactor;
					
		}
		
		

	}
}